<?php
/**
 * TomatoCMS
 *
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@tomatocms.com so we can send you a copy immediately.
 *
 * @copyright    Copyright (c) 2009-2010 TIG Corporation (http://www.tig.vn)
 * @license        http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @version     $Id: add.phtml 3032 2010-05-25 08:00:42Z huuphuoc $
 */
?>
<?php
$this->headTitle($this->translator('enterprise_add_page_title'));
$this->headLink()
    ->appendStylesheet($this->APP_STATIC_SERVER . '/js/jquery.ui/themes/base/ui.all.css')
    ->appendStylesheet($this->APP_STATIC_SERVER . '/js/jquery.ui/themes/base/ui.datepicker.css');

$this->headScript()
    ->appendFile($this->APP_STATIC_SERVER . '/js/jquery.validate/jquery.validate.min.js')
    ->appendFile($this->APP_STATIC_SERVER . '/js/jquery.ui/ui.datepicker.js');
?>

<div class="grid_12 t_a_ui_breadcrumb">
    <span><a href="<?php echo $this->url(array(), 'enterprise_enterprise_list'); ?>"><?php echo $this->translator('enterprise_list_breadcump'); ?></a></span>
    <span><?php echo $this->translator('enterprise_add_breadcump'); ?></span>
</div>

<div class="grid_12"><?php echo $this->flashMessenger(); ?></div>

<form method="post" action="<?php echo $this->url(array(), 'enterprise_enterprise_add'); ?>" id="addEnterpriseForm">
<div class="grid_12 t_a_bottom"><?php echo $this->translator('enterprise_add_guide'); ?></div>

<div class="grid_12 t_a_bottom">
    <div class="prefix_1 suffix_1">
        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('enterprise_company_name_vn'); ?>:</label>
            <input type="text" id="company_name_vn" name="company_name_vn" style="width: 300px" />
        </div>

        <hr/>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('enterprise_company_name_en'); ?>:</label>
            <input type="text" id="company_name_en" name="company_name_en" style="width: 300px" />
        </div>

        <hr/>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('enterprise_professtions'); ?>:</label>
            <div style="border:1px solid #222222; padding: 5px; width:610px;overflow:auto;height:200px">
                <?php for ($i = 0; $i < count($this->professions); $i++) : ?>
                <div style="width:195px; float:left; font-size:7pt; padding-left:2px;">
                    <input type="checkbox" id="professions_id[]" name="professions_id[]" value="<?php echo $this->professions[$i]->professions_id; ?>" > <?php echo $this->professions[$i]->professions_name; ?><br>
                </div>
                <?php endfor; ?>
            </div>
        </div>

        <hr/>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('enterprise_currency'); ?>:</label>
            <select id="currency" name="currency" style="width:170px">
                <option value="">---</option>
                <?php foreach($this->currency as $row):?>
                <option value="<?php echo $row->currency_name;?>"><?php echo $row->currency_name;?></option>
                <?php endforeach;?>
            </select>
        </div>

        <hr/>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('enterprise_contact_email'); ?>:</label>
            <input type="text" id="contact_email" name="contact_email" style="width: 300px" />
        </div>

        <hr/>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('enterprise_contact_tel'); ?>:</label>
            <input type="text" id="contact_tel" name="contact_tel" style="width: 170px" />
        </div>

        <hr/>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('enterprise_contact_fax'); ?>:</label>
            <input type="text" id="contact_fax" name="contact_fax" style="width: 170px" />
        </div>

        <hr/>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('enterprise_contact_address'); ?>:</label>
            <input type="text" id="contact_address" name="contact_address" style="width: 300px" />
        </div>

        <hr/>

        <div class="clearfix t_a_bottom">
            <label style="line-height:15px;height:1px">&nbsp;</label>
            <span style="font-weight:bold;"><?php echo $this->translator('enterprise_account');?> VND:</span>
        </div>

        <hr/>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('enterprise_bank_name'); ?>:</label>
            <input type="text" id="bank_name_vnd" name="bank_name_vnd" style="width: 300px" />
        </div>

        <hr/>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('enterprise_bank_account'); ?>:</label>
            <input type="text" id="bank_account_vnd" name="bank_account_vnd" style="width: 170px" />
        </div>

        <hr/>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('enterprise_bank_account_owner'); ?>:</label>
            <input type="text" id="bank_account_owner_vnd" name="bank_account_owner_vnd" style="width: 300px" />
        </div>

        <hr/>

        <div class="clearfix t_a_bottom">
            <label style="line-height:15px;height:1px">&nbsp;</label>
            <span style="font-weight:bold;"><?php echo $this->translator('enterprise_account');?> USD:</span>
        </div>

        <hr/>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('enterprise_bank_name'); ?>:</label>
            <input type="text" id="bank_name_usd" name="bank_name_usd" style="width: 300px" />
        </div>

        <hr/>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('enterprise_bank_account'); ?>:</label>
            <input type="text" id="bank_account_usd" name="bank_account_usd" style="width: 170px" />
        </div>

        <hr/>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('enterprise_bank_account_owner'); ?>:</label>
            <input type="text" id="bank_account_owner_usd" name="bank_account_owner_usd" style="width: 300px" />
        </div>

        <hr/>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('enterprise_registration_number'); ?>:</label>
            <input type="text" id="registration_number" name="registration_number" style="width: 300px" />
        </div>

        <hr/>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('enterprise_registration_date'); ?>:</label>
            <input type="text" id="registration_date" name="registration_date" style="width: 100px" />
        </div>

        <hr/>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('enterprise_registration_city'); ?>:</label>
            <input type="text" id="registration_city" name="registration_city" style="width: 300px" />
        </div>

        <hr/>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('enterprise_frontend_active'); ?>:</label>
            <select id="frontend_active" name="frontend_active" style="width:170px">
                <option value="0">---</option>
                <option value="1"><?php echo $this->translator('enterprise_frontend_status_active'); ?></option>
                <option value="0"><?php echo $this->translator('enterprise_frontend_status_inactive'); ?></option>
            </select>
        </div>

        <hr/>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('enterprise_backend_active'); ?>:</label>
            <select id="backend_active" name="backend_active" style="width:170px">
                <option value="0">---</option>
                <option value="1"><?php echo $this->translator('enterprise_backend_status_active'); ?></option>
                <option value="0"><?php echo $this->translator('enterprise_backend_status_inactive'); ?></option>
            </select>
        </div>

        <hr/>

        <div class="clearfix t_a_bottom">
            <label>&nbsp;</label>
            <button type="submit"><span><?php echo $this->translator('enterprise_add_save_button'); ?></span></button>&nbsp;&nbsp;&nbsp;
            <button type="reset"><span><?php echo $this->translator('enterprise_reset_button'); ?></span></button>
        </div>
    </div>
</div>
</form>

<script type="text/javascript">

$(document).ready(function() {

    /**
    * Create datepicker instances
    */
    $('#registration_date').datepicker({ dateFormat: 'dd/mm/yy' });
    
    // EDIT - STAR : KHANH; 25/04/2011; Kiem tra so dien thoai co dau +
    $.validator.addMethod('check_fonenumber', function(value) {
		var str = value;
		var the_char = str.charAt(0);
		
		if(the_char=="+")
		{
			str = str.split(' ').join(''); ;	// Remove Spaces
			var len = str.length;
			
			for(i=1; i<len; i++) // bat dau tu ky tu sau dau "+"
			{
				if(str[i]=="0")
				{
					
				}
				else if(!parseInt(str[i]))				
				{ return false; }
			}	
		}
		else
		{ return false;	}
	
		return true;
	});
	// EDIT - STOP
	
    $('#addEnterpriseForm').validate({
        rules: {
            company_name_vn: {
                required: true,
                maxlength: 255
            },
            company_name_en:{
                maxlength: 255
            },
            contact_email:{
                required: true,
                email:true
            },
            registration_number:{
                required: true
            },
            registration_date:{
                required: true
            },
            registration_city:{
                required: true
            },
            currency:{
                required: true,
            },
            contact_tel:{
                required: true,
                //number: true,
                check_fonenumber: true
            },
            contact_fax:{
                required: true,
                //number: true,
                check_fonenumber: true
            },
            contact_address:{
                required: true
            }
            ,
            bank_name_vnd:{
                required: true
            }
            ,
            bank_account_vnd:{
                required: true
            }
            ,
            bank_account_owner_vnd:{
                required: true
            }
        },
        messages: {
            company_name_vn: {
                required: "<?php echo $this->translator('enterprise_company_name_vn_required'); ?>",
                maxlength: "<?php echo $this->translator('enterprise_company_name_vn_maxlength'); ?>"
            },
            company_name_en: "<?php echo $this->translator('enterprise_company_name_en_maxlength'); ?>",
            contact_email: {
                required: "<?php echo $this->translator('enterprise_contact_email_required'); ?>",
                email: "<?php echo $this->translator('enterprise_invalid_email'); ?>"
            },
            registration_number: "<?php echo $this->translator('enterprise_registration_number_required'); ?>",
            registration_date: "<?php echo $this->translator('enterprise_registration_date_required'); ?>",
            registration_city: "<?php echo $this->translator('enterprise_registration_city_required'); ?>",
            currency: "<?php echo $this->translator('enterprise_currency_required'); ?>",
            contact_tel: {
                required: "<?php echo $this->translator('enterprise_contact_tel_required'); ?>",
                check_fonenumber: "<?php echo $this->translator('enterprise_contact_tel_invalid_number'); ?>"
            },
            contact_fax: {
                required: "<?php echo $this->translator('enterprise_contact_fax_required'); ?>",
                check_fonenumber: "<?php echo $this->translator('enterprise_contact_fax_invalid_number'); ?>"
            },
            contact_address: "<?php echo $this->translator('enterprise_contact_address_required'); ?>",
            bank_name_vnd: "<?php echo $this->translator('enterprise_bank_name_required'); ?>",
            bank_account_vnd: "<?php echo $this->translator('enterprise_bank_account_required'); ?>",
            bank_account_owner_vnd: "<?php echo $this->translator('enterprise_bank_account_owner_required'); ?>",
        }
    });
});
</script>
